package com.atguigu.yygh.task.yyghtask;

import com.atguigu.mq.consts.MqConst;
import com.atguigu.mq.service.RabbitService;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@EnableScheduling //开启spring定时任务
public class YyghTest {

    @Autowired
    RabbitService rabbitService;

    //一个定时任务就是一个方法，标注注解指定cron表达式
    @Scheduled(cron = "8 * * * * ?")//每分钟内的第八秒
    public void aa(){
        System.out.println(new Date());

        String reserve_date = new DateTime().plusDays(1).toString("yyyy-MM-dd");

        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_8,reserve_date);
    }




}
